%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% File:               predicted_probs2.m
%
% Authors:            Sergio Ascencio and Miguel Rueda
%
% Description:        computes predicted action probabilitites      
%
% Language:           MATLAB R2013b (8.2.0.701) 64 Bit
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function [p_PAN,p_PRI,p_PRD]=predicted_probs2(beta,X_PRI,X_PAN,X_PRD)


betas=reshape(beta,[size(X_PAN,2),6]);

%Base outcome is L (minimum representation) order of coefficients L, M, H
betas_PRI=[zeros(size(X_PRI,2),1) betas(:,1:2)];
betas_PAN=[zeros(size(X_PAN,2),1) betas(:,3:4)];
betas_PRD=[zeros(size(X_PRD,2),1) betas(:,5:6)];

p_PRD=exp(X_PRD*betas_PRD)./kron(ones(1,3),sum(exp(X_PRD*betas_PRD),2));
p_PAN=exp(X_PAN*betas_PAN)./kron(ones(1,3),sum(exp(X_PAN*betas_PAN),2));
p_PRI=exp(X_PRI*betas_PRI)./kron(ones(1,3),sum(exp(X_PRI*betas_PRI),2));

end

